package api;

import conf.APP;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import utils.HttpClientUtils;
import utils.ResponseData;

import java.util.HashMap;
import java.util.Map;

public class LoginApi {
    private static final String loginUrl = APP.BASE_URL + "/system/public/verifyLogin";
    private static final Logger logger = LoggerFactory.getLogger(CommonApi.class);

    public ResponseData login(String name, String password, String code) throws Exception {
        Map<String, String> message = new HashMap<>();
        if (name != null) {
            message.put("username", name);
        }
        if (password != null) {
            message.put("password", password);

        }
        if (code != null) {
            message.put("valicode", code);

        }
        ResponseData responseData = HttpClientUtils.post(loginUrl, message);
        logger.info("响应报文为{}", responseData);

        return responseData;
    }
}
